import sys
from PySide2.QtWidgets import QApplication, QMainWindow, QLCDNumber, QRadioButton, QButtonGroup
from PySide2.QtCore import QObject
from PySide2.QtUiTools import QUiLoader

class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()


        loader = QUiLoader()
        self.ui = loader.load(r'D:\TimeCount\venv\ui\mainWindows1.0.ui')
        self.setCentralWidget(self.ui)
        self.setFixedSize(self.ui.size())


        self.ui.UpdateSetings.clicked.connect(self.print_test)

        self.lcdNumber = self.ui.findChild(QLCDNumber, 'LcdShow')
        self.initRunMode()
        self.RunMode = '定时器'

        self.lcdShowDisplay('00:00')

    def initRunMode(self):
        self.bgt = QButtonGroup()

        self.Clock = self.ui.findChild(QRadioButton, 'Clock')
        self.Timer = self.ui.findChild(QRadioButton, 'Timer')
        self.Counter = self.ui.findChild(QRadioButton, 'Counter')
        self.SecondChronograph=self.ui.findChild(QRadioButton, 'SecondChronograph')

        self.bgt.addButton(self.Clock)
        self.bgt.addButton(self.Timer)
        self.bgt.addButton(self.Counter)
        self.bgt.addButton(self.SecondChronograph)


        self.bgt.buttonClicked.connect(self.check_mode_from_radioButton)

    def print_test(self):
        print('测试')

    def lcdShowDisplay(self, timeShow):
        self.lcdNumber.display(timeShow)

    def check_mode_from_radioButton(self, sender):
        print(sender)
        if sender.isChecked():
            self.RunMode = sender.text()
            print(self.RunMode)

# if __name__ == '__main__':
#     app = QApplication([])
#     mainwindow = MainWindow()
#     mainwindow.show()
#     sys.exit(app.exec_())
